/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ramuanajaib;

import java.util.Vector;

public class Potion implements GameConstant {

    private Vector<Ingredients> ingredients;
    private Vector<Integer> ingredients_number;
    private int effect;

    public Potion() {
        ingredients = new Vector<Ingredients>();
        ingredients_number = new Vector<Integer>();
    }

    /*-----------------------------------------------------------------*/
    /* Fungsi ini buat ngecek bahan dengan kategori yang dimaksud ada  */
    /* di bahan yang dipilih ato nggak                                 */
    /*-----------------------------------------------------------------*/
    public int IngredientExist(int category) {
        for (int i = 0; i < ingredients.size(); i++) {
            if (category == ingredients.get(i).getCategory()) {
                return i;
            }
        }

        return -1;
    }

    /*-----------------------------------------------------------------*/
    /* Fungsi ini buat ngecek bahan dengan kateogri yang dimaksud ada  */
    /* dan jumlah nya sesuai quantity yang dimaksud ato nggak          */
    /*-----------------------------------------------------------------*/
    public int IngredientMatch(int category, int quantity) {
        int idx = IngredientExist(category);

        if (idx == -1) {
            return -1;
        } else {
            return Math.abs(ingredients_number.get(idx) - quantity);
        }
    }

    public void addIngredient(Ingredients ingredient, int number) {
        ingredients.add(ingredient);
        ingredients_number.add(number);
    }

    public int getEffect() {
        return effect;
    }

    public void setEffect(int effect) {
        this.effect = effect;
    }

    public Vector<Ingredients> getIngredients() {
        return ingredients;
    }

    public void setIngredients(Vector<Ingredients> ingredients) {
        this.ingredients = ingredients;
    }

    public Vector<Integer> getIngredients_number() {
        return ingredients_number;
    }

    public void setIngredients_number(Vector<Integer> ingredients_number) {
        this.ingredients_number = ingredients_number;
    }
}
